﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;
using System.IO;

namespace UtopianGame.graphics.menu
{
    class RegionScreen : BaseMenu
    {
        int regionNumber;
  
        public RegionScreen(ContentManager cm, String newMessage, int currentRegion)
        {
            init(cm, newMessage, currentRegion);

        }
        protected void init(ContentManager cm, String newMessage, int currentRegion)
        {
            base.init(cm);
            spriteName = "regionScreen";
            sprite = cm.Load<Texture2D>(spriteName);
            boundingBox.Width = 750;
            boundingBox.Height = 550;

            regionNumber = currentRegion;

            //Close button in the center of screen
            int centerAlignmentNumber;
            centerAlignmentNumber = boundingBox.X + (boundingBox.Width / 2);
            centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString("Close").X) / 2);

            addToSubObjectList(new CloseMenuButton(contentManager), centerAlignmentNumber, 500, 500);
        }

        public override void draw(SpriteBatch sb)
        {
            base.draw(sb);

            //Statistics
            sb.DrawString(GlobalDataHolder.baseFont, "Population:" + Nation.regionList[regionNumber].populationCount, new Microsoft.Xna.Framework.Vector2(600, 200), Color.Black);
            sb.DrawString(GlobalDataHolder.baseFont, "Health Rate:" + Nation.regionList[regionNumber].healthIndex + "%", new Microsoft.Xna.Framework.Vector2(600, 250), Color.Black);
            sb.DrawString(GlobalDataHolder.baseFont, "Crime Rate:" + Nation.regionList[regionNumber].crimeIndex + "%", new Microsoft.Xna.Framework.Vector2(600, 300), Color.Black);
            sb.DrawString(GlobalDataHolder.baseFont, "Literacy Rate:" + Nation.regionList[regionNumber].educationIndex + "%", new Microsoft.Xna.Framework.Vector2(600, 350), Color.Black);
            sb.DrawString(GlobalDataHolder.baseFont, "Cost Of Living:$" + Nation.regionList[regionNumber].costOfLiving, new Microsoft.Xna.Framework.Vector2(600, 400), Color.Black);
            sb.DrawString(GlobalDataHolder.baseFont, "Average Income: $" + Nation.regionList[regionNumber].averageIncome, new Microsoft.Xna.Framework.Vector2(600, 450), Color.Black);
            sb.DrawString(GlobalDataHolder.baseFont, "People in Poverty: " + Nation.getPovertyCount(regionNumber), new Microsoft.Xna.Framework.Vector2(600, 500), Color.Black);
        
            //Infrastructure List
            sb.DrawString(GlobalDataHolder.baseFont, "Built Infrastructure:", new Microsoft.Xna.Framework.Vector2(150, 200), Color.Black);
            for (int i = 0; i < Nation.regionList[regionNumber].infrastructureList.Count; i++)
            {
                String infrastructureName = Nation.regionList[regionNumber].infrastructureList[i];
                int stringYCoord = 200 + ((i + 1) * 32);
                sb.DrawString(GlobalDataHolder.baseFont, infrastructureName, new Microsoft.Xna.Framework.Vector2(150, stringYCoord), Color.Black);
            }
        }
    }
}